<%--
  Created by IntelliJ IDEA.
  User: xin
  Date: 2024/10/22
  Time: 上午11:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="java.util.*" contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="com.example.skycode5.dao.AdminDao" %>
<%
    request.setCharacterEncoding("UTF-8");
    //判断shif点击登录
    String Action = request.getParameter("Action");
    if(Action!= null && Action.equals("login")){
        String User = request.getParameter("User");
        String Pwd = request.getParameter("Pwd");
        AdminDao adminDao = new AdminDao();
       boolean isOK= adminDao.CheckLogin(User, Pwd);
       if (isOK){
           //使用缓存技术记录账号密码信息
           session.setAttribute("User",User);//会话记录账号信息
           out.println("<script>alert('登录成功！');location.href='index.jsp';</script>");
       }else {
           session.setAttribute("User",User);//清空用户信息
           out.println("<script>alert('登录失败！');location.href='index.jsp';</script>");
       }
    }
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="GBK">
    <title> 后台登陆-天马行空学习建站</title>
    <link rel="stylesheet" href="static/css/amazeui.min.css">
    <script src="static/js/main.js"></script>
</head>
<!--引入背景图-->
<body style="background: url(static/img/login-bg.png)no-repeat">
<div class="header"style="text-align: center;margin-top: 100px;">
    <div class="am-g">
        <img src="static/img/loginTitle.png">
        </div>
    </div>
<!--登录框-->
<div class="am-g"style="margin-top: 20px;">
    <div class="am-u-lg-6 am-u-md-10 am-u-sm-centered">
        style=background-color: url(static/img/login-bg.png)no-repeat;haight:479px;width:695px">
        <!--登录表单-->
        <form action="login.jsp" method="post" class="am-form long-form">
            style="padding:50px 0px 0px 120px;width:550px"
            onsubmit="return LongCheck()">
            <label for="name" >用户名：</label><input type="text" id="name" name="User" id="User" value=""><br><label for="ps">密码:</label>
            <input type="password" id="ps" name="Pwd" id="Pwd" value=""><br>
            <!--登陆页面-->
            <div class="am-cf">
                <input type="hidden" name="Action" value="login"><input
            type="submit" value="登录"id="save"
            style="width: 100%;border-radius: 0.5em;"
            class="am-but am-but-primary am-btn-sm am-round">

    </div>
        </form>
    </div>
</div>
</body>
</html>
